<script>
import Common from "@/mixins/order/commonbg.js";
import OrderService from "@/api/order/OrderService.js";
import PPMForm from "@/crm3.0part7-ppm/core/ppmForm.vue";

export default {
  name: "mstp10460067",
  mixins: [PPMForm, Common],
  data() {
    return {
      //MSTP	非正常变更	停开
      // proName: 'MSTP'
      startDate:{
        disabledDate(time) {
          return time.getTime() < Date.now() - 3600 * 1000 * 24 * 1;//限制初始日期
        }
      }
    };
  },
  mounted() {
    this.initCommon();
    this.StartDate();
  },

  computed: {},
  methods: {
    async initCommon() {
      let lastStateCd = JSON.parse(
        sessionStorage.getItem("changeRow")
      ).lastStateCd;
      let conditions = {
        count: 3,
        flag: "1",
      };
      let resList = await OrderService.qryWorkDate(conditions);
      
      let dateStr = resList.meta.date ? resList.meta.date : "";
      // if(dateStr){
      //       dateStr=dateStr.split("-").join('/');
      // }
      
      //1、集团发起的停开单（包括需求单和订单起的），自动带出要求完成日期为3个工作日，且可修改。
      //2.订单起停开展示订单要求完成日期 需求单起停开默认展示需求单要求完成日期
      if (lastStateCd == "50030002") {
        for (let i in this.formData) {
          if (
            this.formData[i].colId == "orderDate" ||
            this.formData[i].colId == "ORDER_DATE"
          ) {
            //需求单起隐藏订单要求完成日期
            this.formData[i].isshow = false;
            this.SetRequired("0", i);
          }
          if (
            this.formData[i].colId == "reqOrderDate" ||
            this.formData[i].colId == "REQ_ORDER_DATE"
          ) {
            //需求单起隐藏订单要求完成日期
            this.formData[i].value = dateStr;
          }
        }
      } else {
        for (let i in this.formData) {
          if (
            this.formData[i].colId == "reqOrderDate" ||
            this.formData[i].colId == "REQ_ORDER_DATE"
          ) {
            //订单起隐藏需求单要求完成日期
            this.formData[i].isshow = false;
            this.SetRequired("0", i);
          }
          if (
            this.formData[i].colId == "orderDate" ||
            this.formData[i].colId == "ORDER_DATE"
          ) {
            //需求单起隐藏订单要求完成日期
            this.formData[i].value = dateStr;
          }
        }
      }
    },
    StartDate(key) {
      // if(key == '10460460-100012033'){
        return this.startDate;
      // }
    },
  },
};
</script>

